import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   
   {
    title: '学/工号',//,唯一编码',
    align:"center",
    dataIndex: 'code',
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '所在部门',
    align:"center",
    dataIndex: 'departmentId_dictText'
   },
   {
    title: '通道',
    align:"center",
    dataIndex: 'channelId_dictText',
   },
    {
    title: '规则',
    align:"center",
    dataIndex: 'ruleName',
   },
   {
    title: '授权类型',
    align:"center",
    dataIndex: 'authType',
     customRender: ({ text }) => {
       return render.renderDict(text, 'auth_type');
     },
   },
   {
    title: '开始时间',//
    align:"center",
    dataIndex: 'startDate',
   },
   {
    title: '结束时间',//
    align:"center",
    dataIndex: 'endDate',
   },
  
  
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "部门",
    field: 'departmentId',
    component : 'JSelectDept',
    componentProps:{
      multiple:false,
      checkable:false,
    }
  },
	{
      label: "学/工号",//,唯一编码",
      field: 'code',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "姓名",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
 	},
  {
    label: '下发状态',
    field: 'distributeStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"distributeStatus",
    }
  },
  {
    field: 'channelId',
    component: 'Input',
    label: "",
    slot:'channel',
    //colProps: {span: 6},
 },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    field: '',
    component: 'Divider',
    label: '授权设置',
    colProps: {span: 24},

  },
  {
    label: '通道',//',
    field: 'channelId',
    component: 'JDictSelectTag',
    slot: 'channelSlot',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择规则!'},
          ];
     },
    colProps: {span: 8},

  },
  {
    label: '规则',//',
    field: 'ruleId',
    component: 'JDictSelectTag',
    slot: 'ruleSlot',
    // componentProps:{
    //   dictCode:"ac_rule,ruleName,id",
    // },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择规则!'},
          ];
     },
    colProps: {span: 8},

  },
  {
    label: '授权类型',
    field: 'authType',
    component: 'JDictSelectTag',
    // labelWidth : '300px',
    componentProps:{
      dictCode:'auth_type',
      // style: 'widht:300px;',
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择授权类型!'},
          ];
     },
    colProps: {span: 8},

  },
 
  {
    label: '开始时间',
    field: 'startDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
     dynamicRules: ({model,schema}) => {
      return [
        { required: model.authType=='c' ? true : false,},
    ]},
    show:({values}) =>{
        return values.authType=='c' ? true : false
    },
    colProps: {span: 8},
     
  },
  {
    label: '结束时间',
    field: 'endDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    colProps: {span: 8},
    show:({values}) =>{
      return values.authType=='c' ? true : false
    },
     dynamicRules: ({model,schema}) => {
      return [
        { required: model.authType=='c' ? true : false,},

    ]},
  },
  {
    field: '',
    component: 'Divider',
    label: '授权人员',
    colProps: {span: 24},
  },
  {
    label: '人员分组',
    field: 'groupIdList',
    component: 'JDictSelectTag',
    slot: 'groupIdListSlot',
    // componentProps:{
    //   dictCode:"ac_group,group_name,id",
    //   mode: 'tags'
    // },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择分组!'},
          ];
    },
    colProps: {span: 24},
  },
  {
    label: '人员',
    field: 'personIds',
    component: 'JSelectGroupPerson',
    slot: 'personSlot',
    // componentProps:{
    //   // isRadioSelection:true,
    //   labelKey: 'name',
    //   valueKey: 'id',
    //   params:{'code':20240408},
    // },
    colProps: {span: 24},
  },
  // {
  //   label: '部门',
  //   field: 'departmentId',
  //   component: 'JSelectDept',
  //   componentProps:{
  //     isRadioSelection:true,
  //   },
  //   colProps: {span: 8},
  //   dynamicRules: ({model,schema}) => {
  //         return [
  //                { required: true, message: '请选择部门!'},
  //         ];
  //    },

  // },

  // {
  //   label: '姓名',
  //   field: 'name',
  //   component: 'Input',
  //   dynamicRules: ({model,schema}) => {
  //         return [
  //                { required: false, message: '请输入姓名!'},
  //         ];
  //    },
  // },
  // {
  //   label: '学/工号',
  //   field: 'code',
  //   component: 'Input',
  //   dynamicRules: ({model,schema}) => {
  //         return [
  //                { required: false, message: '请选择学/工号!'},
  //         ];
  //    },
  // },
  

	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//表单数据
export const rowFormSchema: FormSchema[] = [
  {
    field: '',
    component: 'Divider',
    label: '授权设置',
    colProps: {span: 24},
  },
  
  {
    label: '通道',//',
    field: 'channelId',
    component: 'JDictSelectTag',
    slot: 'channelSlot',
    colProps: {span: 8},
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择规则!'},
          ];
     },
  },
  {
    label: '规则',//,唯一编码',
    field: 'ruleId',
    component: 'JDictSelectTag',
    slot: 'ruleSlot',
    // componentProps:{
    //   dictCode:"ac_rule,ruleName,id",
    // },
    colProps: {span: 8},
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false, message: '请选择规则!'},
          ];
     },
  },
  {
    label: '授权类型',
    field: 'authType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'auth_type',
    },
    colProps: {span: 8},
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择授权类型!'},
          ];
     },
  },
  {
    label: '开始时间',
    field: 'startDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    colProps: {span: 8},
    show:({values}) =>{
      return values.authType=='c' ? true : false
    },
     dynamicRules: ({model,schema}) => {
      return [
        { required: model.authType=='c' ? true : false,},

    ]},
     
  },
  {
    label: '结束时间',
    field: 'endDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
     show:({values}) =>{
      return values.authType=='c' ? true : false
    },
     dynamicRules: ({model,schema}) => {
      return [
        { required: model.authType=='c' ? true : false,},

    ]},
  },
  {
    label: '部门',
    field: 'departmentId',
    component: 'JSelectDept',
    componentProps:{
      isRadioSelection:true,
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择部门!'},
          ];
     },
     ifShow: false,

  },
  {
    field: '',
    component: 'Divider',
    label: '授权人员',
    colProps: {span: 24},
  },
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
    componentProps:{
      disabled: true
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false, message: '请输入姓名!'},
          ];
     },
     ifShow: true,
    colProps: {span: 8},

  },
  {
    label: '学/工号',
    field: 'code',
    component: 'Input',
    componentProps:{
      disabled: true
    },
    colProps: {span: 8},
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false, message: '请选择学/工号!'},
          ];
     },
     ifShow: true,
  },
 
  // {
  //   label: '分组',
  //   field: 'groupIdList',
  //   component: 'JDictSelectTag',
  //   componentProps:{
  //     dictCode:"ac_group,group_name,id",
  //     mode: 'tags'
  //   },
  //   dynamicRules: ({model,schema}) => {
  //         return [
  //                { required: true, message: '请选择分组!'},
  //         ];
  //    },
  //    ifShow: false,

  // },
  {
	  label: '',
	  field: 'personId',
	  component: 'Input',
	  show: false
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//列表数据
export const deviceColumns: BasicColumn[] = [
  {
    title: '设备编号',
    align:"center",
    dataIndex: 'deviceCode'
   },
   {
    title: '设备名称',
    align:"center",
    dataIndex: 'deviceName'
   },
   {
    title: '设备类型',
    align:"center",
    dataIndex: 'deviceType',
     customRender: ({ text }) => {
       return render.renderDict(text, 'deviceType');
     },
   },
];

export const deviceResultColumns: BasicColumn[] = [
  {
   title: '设备名称',
   align:"center",
   dataIndex: 'deviceName'
  },
  {
   title: '下发状态',
   align:"center",
   dataIndex: 'distributeStatus',
    customRender: ({ text }) => {
      return render.renderDict(text, 'distributeStatus');
    },
  },
];

export const deviceSearchFormSchema: FormSchema[] = [
	{
      label: "设备编码",
      field: 'deviceCode',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      colProps: {span: 6},
 	},
];

export const deviceResultSearchFormSchema: FormSchema[] = [
	// {
  //     label: "设备编码",
  //     field: 'deviceCode',
  //     component: 'Input',
  //     colProps: {span: 6},
 	// },
	{
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      colProps: {span: 6},
 	},
];

// 高级查询数据
export const superQuerySchema = {
  code: {title: '学/工号',order: 0,view: 'text', type: 'string',},
  name: {title: '人员姓名',order: 1,view: 'text', type: 'string',},
  sex: {title: '性别',order: 2,view: 'number', type: 'number',},
  birthday: {title: '生日',order: 3,view: 'datetime', type: 'string',},
  paperType: {title: '证件类型',order: 4,view: 'number', type: 'number',},
  paperTypeName: {title: '证件类型名称',order: 5,view: 'text', type: 'string',},
  paperNumber: {title: '证件号码',order: 6,view: 'text', type: 'string',},
  nation: {title: '民族',order: 7,view: 'number', type: 'number',},
  phone: {title: '电话',order: 8,view: 'text', type: 'string',},
  email: {title: '邮件',order: 9,view: 'text', type: 'string',},
  departmentId: {title: '部门编号',order: 10,view: 'number', type: 'number',},
  status: {title: '人员状态',order: 11,view: 'number', type: 'number',},
  password: {title: '私人密码',order: 12,view: 'text', type: 'string',},
  memo: {title: '备注',order: 13,view: 'text', type: 'string',},
  ownerCode: {title: '所属组织编码',order: 14,view: 'text', type: 'string',},
  createUser: {title: '创建人',order: 15,view: 'text', type: 'string',},
  updateUser: {title: '更新人',order: 16,view: 'text', type: 'string',},
  namePinyin: {title: '人员名称拼音',order: 18,view: 'text', type: 'string',},
  recordUpdateTime: {title: '数据更新时间',order: 19,view: 'datetime', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
